package edu.cuit.canary.selection;

import java.util.Scanner;

public class SwitchDemo4 {
    public static void main(String[] args) {
        System.out.println("请输入月份:");
        Scanner input = new Scanner(System.in);
        int month = input.nextInt();
        System.out.println("请输入年份:");
        int year = input.nextInt();
        input.close();

        switch (month){
            case 1,3,5,7,8,10,12 ->
                System.out.println("该月有31天");
            case 2 -> {
                if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                    System.out.println("该月有29天");
                else
                    System.out.println("该月有28天");
            }
            case 4, 6,9,11 ->
                System.out.println("该月有30天");
            default ->
                System.out.println("非法的月份");
        }

    }
}
